package com.example.books.Service.Impl;

import com.example.books.Dao.UserDao;
import com.example.books.Pojo.UserDO;
import com.example.books.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

@Service
public class UserServiceimpl implements UserService {

    @Autowired
    private UserDao userDao;


    @Override
    public List<UserDO> query(Map<String, Object> map) {
        return userDao.query(map);
    }

    @Override
    public boolean create(UserDO userDO) {
        UserDO getuser = userDao.getuser(userDO.getUsername());
        if (getuser==null){
            return userDao.create(userDO);
        }else {
            return false;
        }
    }

    @Override
    public boolean update(UserDO userDO) {
        return userDao.update(userDO);
    }

    @Override
    public boolean delete(Map<String, Object> map) {
        return userDao.delete(map);
    }

    @Override
    public List<UserDO> search( @RequestBody Map<String, Object> map) {
        return userDao.search(map);
    }

    @Override
    public boolean uploadImg(Map<String, Object> map) {
        return userDao.uploadImg(map);
    }
}
